package com.eazy.lkv2.web.service.system.impl;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.eazy.lkv2.core.db.ZQ;
import com.eazy.lkv2.core.web.utils.DateUtils;
import com.eazy.lkv2.core.web.utils.StrKit;
import com.eazy.lkv2.web.entity.Log;
import com.eazy.lkv2.web.service.system.SystemLogService;
import com.rework.joss.persistence.convention.BaseDao;

@Service
public class SystemLogServiceImpl extends BaseDao<Log, String> implements SystemLogService {

	public List<Map<String,Object>> select() {
		return sqlSessionTemplate.selectList(getMapperMethodId("select"));
	}

	@Override
	public List<Map<String, Object>> browserCount() {
		return sqlSessionTemplate.selectList(getMapperMethodId("browserCount"));
	}

	@Override
	public List<Map<String, Object>> selectRefCount(String beginTime, String endTime) {
		String sql = "select DATE_FORMAT(create_date, '%Y-%m-%d %H:%i:%s') AS tim,log.* from log where 1=1 ";
		if(StrKit.notEmpty(beginTime) && StrKit.notEmpty(endTime)) {
			sql += " and CREATE_DATE>='" + beginTime + "' ";
			sql += " and CREATE_DATE<='" + endTime + "' ";
		} else {
			sql += " and CREATE_DATE like '" + DateUtils.getNowTime() + "%' ";
		}
		sql += " order by CREATE_DATE desc";
		return ZQ.commonResult(sql, null);
		//return sqlSessionTemplate.selectList(getMapperMethodId("selectRefCount"),new Object[]{string,string2});
	}
}
